﻿<!-- #Include File="../Include/Admin_Onlogin.asp" -->
<%
Dim TopDir,FsoFile,AllFileSize
Dim DirFiles,DirFolder
strFileName = "Admin_CssFileSelect.asp"
TopDir=Replace(InstallDir&SkinDir,"//","/")
Select Case Action
Case Else
	Call Main()
End Select
Set Fso = Nothing

Sub Main()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		On Error Resume Next
		Set FsoFile = Fso.GetFolder(Server.MapPath(TopDir))
		If Err or TopDir="/" Then
			Set FsoFile = Nothing
			Response.Write "找不到目录，可能参数配置错误！"
			Response.End()
		End If
		AllFileSize = FsoFile.size
		Dim FileNums,i
		FileNums = FsoFile.Files.count
		totalPut = FileNums
		i=0
		For Each DirFiles in FsoFile.Files
			strFileType=lcase(mid(DirFiles.Name,instrrev(DirFiles.Name,".")+1))
			If strFileType="css" Then
				If data="" Then
					data = data & "{""name"":"""&ToUnicode(DirFiles.name)&""",""getname"":"""&ToUnicode(GetMobanName(DirFiles.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(DirFiles.name))&""",""ico"":""../Plugins/assets/images/ext/css.png"",""size"":"""&GetSize(DirFiles.size,"b")&""",""time"":"""&Time_Type(DirFiles.DateLastModified,1)&"""}"
				Else
					data = data & ",{""name"":"""&ToUnicode(DirFiles.name)&""",""getname"":"""&ToUnicode(GetMobanName(DirFiles.name))&""",""gettype"":"""&ToUnicode(GetMobanTypeName(DirFiles.name))&""",""ico"":""../Plugins/assets/images/ext/css.png"",""size"":"""&GetSize(DirFiles.size,"b")&""",""time"":"""&Time_Type(DirFiles.DateLastModified,1)&"""}"
				End If
			End If
		Next
		Set FsoFile = Nothing
		If totalPut = 0 Then
			Response.Write "{""code"":201,""msg"":""\u65e0\u6570\u636e""}" & vbCrLf
		Else
			Response.Write "{""code"":0,""msg"":""\u83b7\u53d6\u6210\u529f!"",""count"":"&totalPut&",""data"":["&data&"],""rel"":1}" & vbCrLf
		End If
		Response.End()
	Else
		Response.Write "<!DOCTYPE html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<title>选择风格</title>" & vbCrlf
		Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
		Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
		Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
		Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
		Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
		Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"">" & vbCrlf
		Response.Write "function ok(files,size)" & vbCrlf
		Response.Write "{" & vbCrlf
		Response.Write "	var sExt=files.substr(files.lastIndexOf(""."")+1);" & vbCrlf
		Response.Write "	dialogOpener.$S('" & Trim(Request("objname")) & "').value = files;" & vbCrlf
		Response.Write "	ownerDialog.close();" & vbCrlf
		Response.Write "}" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "</head>" & vbCrlf
		Response.Write "<body>" & vbCrlf
		Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrLf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrLf
		Response.Write "        <legend>选择风格</legend>" & vbCrLf
		Response.Write "    </fieldset>" & vbCrLf
		Response.Write "    <table class=""layui-table"" id=""list"" lay-filter=""list""></table>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""name"">" & vbCrLf
		Response.Write "    <img src=""{{d.ico}}"" style=""width:30px;margin-right:10px"">{{d.name}}" & vbCrlf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""action"">" & vbCrLf
		Response.Write "    <a onClick=""ok('{{d.name}}','{{d.size}}');"" class=""layui-btn layui-btn-xs"">选择</a>" & vbCrlf
		Response.Write "    <a onClick=""ItemDialog('CssView','浏览文件！','" & TopDir & "{{d.name}}',800,500);"" class=""layui-btn layui-btn-xs layui-btn-normal"">浏览</a>" & vbCrlf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script>" & vbCrLf
		Response.Write "    layui.use('table', function() {" & vbCrLf
		Response.Write "        var table = layui.table, $ = layui.jquery;" & vbCrLf
		Response.Write "        var tableIn=table.render({" & vbCrLf
		Response.Write "            elem: '#list'," & vbCrLf
		Response.Write "            url: '?Action=Main'," & vbCrLf
		Response.Write "            method: 'post'," & vbCrLf
		Response.Write "            cellMinWidth: 80," & vbCrLf
		Response.Write "            cols: [[" & vbCrLf
		Response.Write "                {field: 'name', title: '文件名称', width: 150, templet: '#name', fixed: true}," & vbCrLf
		Response.Write "                {field: 'getname', title: '文件别名', width: 120}," & vbCrLf
		Response.Write "                {field: 'gettype', title: '模板类型', width: 100}," & vbCrLf
		Response.Write "                {field: 'size', title: '文件大小', width: 100}," & vbCrLf
		Response.Write "                {field: 'time', title: '修改时间', width: 160}," & vbCrLf
		Response.Write "                {title: '操作', width: 120, align: 'center', toolbar: '#action'}" & vbCrLf
		Response.Write "            ]]" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "    });" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "</body>" & vbCrLf & "</html>"
		Set FsoFile = Nothing
	End If
End Sub
%>